package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.Travel;
import cn.wolfcode.trip.base.domain.Travelcontent;
import cn.wolfcode.trip.base.query.StrategyQueryObject;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.service.ITravelContentService;
import cn.wolfcode.trip.base.service.ITravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 大家都在看
 */
@Controller
@RequestMapping("/everybodys")
public class Everybody {

    @Autowired
    private ITravelService travelService;
    @Autowired
    private ITravelContentService travelContentService;

    @Autowired
    private IStrategyService strategyService;


    /**
     * 攻略分页及高查
     * @param qo
     * @param model
     * @return
     */
    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") StrategyQueryObject qo, Model model){
        model.addAttribute("pageInfo",strategyService.query(qo));
        model.addAttribute("strategies",strategyService.listAll());
        return "everybody/list";
    }


    /**
     * 查阅游记文章文本内容
     * @param id : 游记文章的id
     * @return
     */
    @RequestMapping("/read")
    @ResponseBody
    public Travelcontent getContent(Long id){
        return travelContentService.get(id);
    }
}
